package com.st.security.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.st.security.entities.SysPermission;
import com.st.security.mapper.SysPermissionMapper;
import com.st.security.service.SysPermissionService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @创建人: 放生
 * @创建时间: 2022/4/7
 * @描述:
 */
@Service
public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, SysPermission> implements SysPermissionService {
    @Override
    public List<SysPermission> findByUserId(Long userId) {
        if(userId == null) { return null; }
        List<SysPermission> list = baseMapper.selectPermissionByUserId(userId);
        //用户无任何权限时，list会有一个 `null` 空的SysPermission 对象，把那个null移除
        list.remove(null); return list;
    }


}
